<?xml version="1.0" encoding="UTF-8" ?>

<!-- New document created with EditiX at Thu Nov 24 14:10:52 WET 2011 -->

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
	<xsl:output method="html" indent="yes"/>
	
	
    <xsl:param name="query"/>
	<xsl:param name="type">html</xsl:param>
	
	<xsl:template match="/">
	 <xsl:choose>
            <xsl:when test="$type = 'html'">
	<html>
		<head>
			<title>XpertStats XML - Player Details</title>
			<link href="css/bluedream.css" media="screen" rel="stylesheet" type="text/css" />
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
			<link rel="shortcut icon" href="images/logo.ico" />
			<link rel="icon" type="image/gif" href="images/logo.ico" />
			<script type="text/javascript"> 
					 	var query = '<xsl:value-of select="$query"/>';
					 	var xslFile = "xslt/team_page.xslt";
					 	var xmlFile = "team_data.xml"
			</script>
			<script type="text/javascript" src="js/XSLT-sort.js"/> 
		</head>
		<body>
		<div id="wrapper">
			<div id="header">
				<div id="header_content">
					<img src="./images/logo.png"/>
					<div style="float:right; margin-top: 15px;">
				   	<form name="form" id="searchbox">						
						<select id="steam" onchange="javascript:queryGo(document.getElementById('steam').options[document.getElementById('steam').selectedIndex].value)">
						<xsl:for-each select="players/player">
							<option>
								<xsl:attribute name="value"><xsl:value-of select="id" /></xsl:attribute>
								<xsl:value-of select="name"/>
							</option>
						</xsl:for-each>					
						
						</select>
				                    <input type="button" value="search" onclick="javascript:queryGo(document.getElementById('steam').options[document.getElementById('steam').selectedIndex].value)"/>
					</form>
					</div>					
				</div>
				
			</div>  
			<div id="menuStrip">
				<ul class="menu">
					  <li><a href="stadiums_data.xml"><span>Stadiums</span></a></li>
					  <li><a href="teams_data.xml"><span>Teams</span></a></li>
					  <li><a href="players_data.xml"  class="active"><span>Players</span></a></li>
					  <li><a href="fixtures_data.xml"><span>Fixtures</span></a></li>
				</ul>    
			</div>
			

			<xsl:apply-templates select="//player[id = $query]" />
		

		</div>
		<div id="footer">
			<div id="footerD">
				<div id="footerF" class="aligned">XpertStats XML - Desenvolvido no âmbito da cadeira CTXML 2011 @ FCT-UNL</div>
				<div id="footerS" class="aligned">Por: Ricardo Mestre e Nuno Gomes</div>
			</div>
		</div>    
	</body>
		</html>
	</xsl:when>

	<xsl:when test="$type = 'newHTML'">

		<div id="wrapper">
			<div id="header">
				<div id="header_content">
					<img src="./images/logo.png"/>
					<div style="float:right; margin-top: 15px;">
				   	<form name="form" id="searchbox">
						<select id="steam" onchange="javascript:queryGo(document.getElementById('steam').options[document.getElementById('steam').selectedIndex].value)">
						<xsl:for-each select="players/player">
							<option>
								<xsl:attribute name="value"><xsl:value-of select="id" /></xsl:attribute>
								<xsl:value-of select="name"/>
							</option>
						</xsl:for-each>											
						</select>
				                    <input type="button" value="Search" onclick="javascript:queryGo(document.getElementById('steam').options[document.getElementById('steam').selectedIndex].value)"/>
					</form>
					</div>					
				</div>
				
			</div>  
			<div id="menuStrip">
				<ul class="menu">
					  <li><a href="stadiums_data.xml"><span>Stadiums</span></a></li>
					  <li><a href="teams_data.xml"><span>Teams</span></a></li>
					  <li><a href="players_data.xml"  class="active"><span>Players</span></a></li>
					  <li><a href="fixtures_data.xml"><span>Fixtures</span></a></li>
				</ul>    
			</div>
			<xsl:apply-templates select="//player[id = $query]" />
		</div>	
	</xsl:when>
		   <xsl:otherwise>
				<xsl:apply-templates select="//player[id = $query]"/>
			</xsl:otherwise>
	</xsl:choose>
	</xsl:template>
	
	
	<xsl:template match="player">
	<div id="main" style="padding-top: 10px;">  
		<section  class="team">
			<img>
				<xsl:attribute name="src">images/teams/t<xsl:value-of select="substring-after(@id,'team_')"/>.png</xsl:attribute>
				<xsl:attribute name="alt"><xsl:value-of select="stadium"/></xsl:attribute>
			</img>
			<ul>
				<li><span>Name: </span><xsl:value-of select="name"/></li>
				<li><span>Nationality: </span><xsl:value-of select="nationality"/></li>
				<li><span>Birthdate: </span><xsl:value-of select="bday"/> (<xsl:value-of select="number(2011) - number(substring(bday,0,5))"/>)</li>
				<li><span>Nickname: </span><xsl:value-of select="nickname"/></li>
				<li><span>Height: </span><xsl:value-of select="height"/></li>
				<li><span>Weight: </span><xsl:value-of select="weight"/></li>
				<li><span>Prefered Position: </span><xsl:value-of select="position"/></li>
			</ul>
		</section>
		<section  class="lineup">
			<h2>Season Details</h2>
			<ul>
				<li><span>Current Team: </span><a href="javascript:viewTeam('{team_info/id}')"><xsl:value-of select="team_info/name"/></a></li>
				<li><span>Shirt Number: </span><xsl:value-of select="team_info/playerNumber"/></li>
			</ul>
			<h3>Discipline</h3>
			<ul>
				<li><span>Yellow Cards: </span><xsl:value-of select="yellowCards"/></li>
				<li><span>Red Cards: </span><xsl:value-of select="redCards"/></li>
			</ul>
			<h3>Goals</h3>
			<xsl:choose>
				<xsl:when  test="goalsScored/@total &gt; 0">
				<p>Goals Scored: <xsl:value-of select="goalsScored/@total"/></p>
				<h4>Types of goals scored:</h4>
			<ul>
				<li><span>Free Play: </span><xsl:value-of select="goalsScored/freePlay"/></li>
				<li><span>Free Kick: </span><xsl:value-of select="goalsScored/freeKick"/></li>
				<li><span>Counter Attack: </span><xsl:value-of select="goalsScored/counterAttack"/></li>
				<li><span>In Play Cross: </span><xsl:value-of select="goalsScored/inPlayCross"/></li>
				<li><span>Set Piece: </span><xsl:value-of select="goalsScored/setPiece"/></li>
				<li><span>Own Goal: </span><xsl:value-of select="goalsScored/ownGoal"/></li>
				<li><span>Long Shot: </span><xsl:value-of select="goalsScored/longShot"/></li>
				<li><span>Penalty: </span><xsl:value-of select="goalsScored/penalty"/></li>
				<li><span>Pressing: </span><xsl:value-of select="goalsScored/pressing"/></li>
			</ul>
			</xsl:when>
			<xsl:otherwise>
			     <p>No goals scored.</p>
			  </xsl:otherwise>
			  </xsl:choose>
		</section>
		<xsl:if test="count(awards/award) &gt; 0">
			<section class="history">
				<h2>Awards</h2>
				<ul>
				<xsl:for-each select="awards/award">
					<xsl:sort select="@date" order="descending"/>
					<li><span><xsl:value-of select="@date"/> </span><xsl:value-of select="."/></li>
				</xsl:for-each>
				</ul>
			</section>
		</xsl:if>
		
		
		<aside>
			<img>
			<!--	<xsl:attribute name="src">images/players/<xsl:value-of select="substring-after(id,'player_')"/>.jpg</xsl:attribute> -->
			<xsl:attribute name="src">images/players/unknown.png</xsl:attribute>
				<xsl:attribute name="alt"><xsl:value-of select="name"/></xsl:attribute>
				<xsl:attribute name="class">short</xsl:attribute>
			</img>
		</aside>
	</div>
	</xsl:template>

</xsl:stylesheet>
